package com.zzyl.controller;


import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingPlanDto;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingPlanVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursing/plan")
@Api(tags = "护理计划")
public class NursingPlanController extends BaseController{

    @Autowired
    private NursingPlanService nursingPlanService;
    @GetMapping
    @ApiOperation("查询所有护理计划")
    public ResponseResult<List<NursingPlanVo>> getPlanAll(){
        List<NursingPlanVo> nursingPlanVos = nursingPlanService.getPlanAll();
        return success(nursingPlanVos);
    }

    @PostMapping
    @ApiOperation("新增护理计划")
    public ResponseResult addPlan(@RequestBody NursingPlanDto nursingPlanDto){
        nursingPlanService.addPlan(nursingPlanDto);
        return success();
    }

    @GetMapping("/search")
    @ApiOperation("条件分页查询")
    public ResponseResult pagePlan(String name,Integer  pageNum,Integer pageSize,Integer status){
        PageResponse pageResponse = nursingPlanService.selectPage(name, pageNum, pageSize, status);
        return success(pageResponse);
    }

    @GetMapping("/{id}")
    @ApiOperation("根据id查询")
    public ResponseResult getById(@PathVariable Long id){
        NursingPlanVo byiD = nursingPlanService.getByiD(id);
        return success(byiD);
    }

    @PutMapping("/{id}")
    @ApiOperation("修改护理计划")
    public ResponseResult updatePlan(@RequestBody NursingPlanDto nursingPlanDto){
        nursingPlanService.update(nursingPlanDto);
        return success();
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除计划")
    public ResponseResult deleteById(@PathVariable Long id){
        nursingPlanService.deleteById(id);
        return success();
    }

    @PutMapping("/{id}/status/{status}")
    @ApiOperation("启用禁用")
    public ResponseResult statusPlan(@PathVariable Long id,@PathVariable Integer status){
        nursingPlanService.updateStatus(id,status);
        return success();
    }




}
